<template>
<div class="layerRtb layerRtb-threecolumn">
    <three-title :title="{name:'加盟意向'}"></three-title>
    <div class="layerRtb-scroll thinScroll" v-scrollHeight = "84">
        <div class="analyItem" v-if="flg==1">
            <p class="analyItemTit tx-center">加盟意向</p>
            <div class="analyItemCon">
                    <p class="col-md-4">
                        <span class="cLightGray pr8">加盟费</span>
                        <span>{{stageInfo.intention_cost ? (stageInfo.intention_cost==0?'是':'否') : ''}}</span>
                    </p>
                    <p class="col-md-4">
                        <span class="cLightGray pr8">提点</span>
                        <span>{{stageInfo.intention_remind ? (stageInfo.intention_remind==0?'高':'低') : ''}}</span>
                    </p>
                    <p class="col-md-4">
                        <span class="cLightGray pr8">期限</span>
                        <span>{{stageInfo.intention_term ? (stageInfo.intention_term==0?'是':'否') : ''}}</span>
                    </p>
                    <p class="col-md-4">
                        <span class="cLightGray pr8">意见</span>
                        <span>{{stageInfo.intention_opinion ? stageInfo.intention_opinion : ''}}</span>
                    </p>
                    <div class="imgbox imgbox1 col-md-3" style="margin-top: 15px; position: absolute; right: 10px;top: 10px;">
                        <img src="https://gnr.rxjy.com/hrms/static/modules/cur/images/edit_img.png" title="编辑" width="20" class="fr pointer mr5" @click="flg=0">
                    </div>
            </div>
        </div>
        <div class="analyItem" v-if="flg==0">
            <p class="analyItemTit tx-center">加盟意见</p>
            <div class="analyItemCon">
                <p class="col-md-4">
                    <span class="cLightGray pr8">加盟费</span>
                    <select name="set_stage_info_intention_cost" class="width70" v-model="intentionCost">
                        <option value="0">是</option>
                        <option value="1">否</option>
                    </select>
                </p>
                <p class="col-md-4">
                    <span class="cLightGray pr8">提点</span>
                    <select name="set_stage_info_intention_remind" class="width70" v-model="intentionRemind">
                        <option value="0">高</option>
                        <option value="1">低</option>
                    </select>
                </p>
                <p class="col-md-4">
                    <span class="cLightGray pr8">期限</span>
                    <select name="set_stage_info_intention_term" class="width70" v-model="intentionTerm">
                        <option value="0">是</option>
                        <option value="1">否</option>
                    </select>
                </p>
                <p class="col-md-4" style="padding-top: 10px;width: 80%;">
                    <span class="cLightGray pr8">意见</span>
                    <input type="text" v-model="intentionOpinion" class="evaluateStandard" name="set_stage_info_intention_opinion" style="width: 60%;">
                </p>
            </div>
            <div class="imgbox imgbox2 " style="margin-top: 15px; position: absolute; right: 10px;top: 10px;">
                <img src="https://gnr.rxjy.com/hrms/static/modules/cur/images/save_img.png" title="保存" width="20" class="fl pointer mr5" name="update_stage_info_intention" @click="updateStageInfoByleId()">
                <img src="https://gnr.rxjy.com/hrms/static/modules/cur/images/goback_img.png" title="返回" width="20" class="fl pointer mr5" @click="flg=1">
            </div>
        </div>
    </div>
            <div class="analyItem">
            <p class="analyItemTit tx-center">综合</p>
            <div class="analyItemCon">
             <p class="fl">
                    <span class="circlemark circlemark-lightRed"> 待</span>
             </p>
            </div>
        </div>
</div>
</template>
<script>
import { mapGetters, mapMutations } from 'vuex'
import { updateStageInfoByleId } from '../../Resources/Api/index'
export default {
    data () {
        return {
            flg: 1,
            stageInfo: {}, // 用户信息
            intentionCost: 0, // 加盟费：0-是，1-否
            intentionRemind: 0, // 提点：0-高，1-低
            intentionTerm: 0, // 期限：0-是，1-否
            intentionOpinion: '' // 意见
        }
    },
    created () {
        this.stageInfo = this.$route.query.stageInfo
        this.intentionCost = this.stageInfo.intention_cost
        this.intentionRemind = this.stageInfo.intention_remind
        this.intentionTerm = this.stageInfo.intention_term
        this.intentionOpinion = this.stageInfo.intention_opinion
    },
    methods: {
        ...mapMutations({
            setUpdatePlate: `SET_UPDATE_PLATE`
        }),
        // 考察阶段修改用户的加盟意向信息
        updateStageInfoByleId () {
            if (this.intentionOpinion === null || this.intentionOpinion === '') {
                layer.msg('请输入面积开始值')
                return
            }
            updateStageInfoByleId({
                uid: this.leftInfo.uid, // 用户id
                intentionCost: this.intentionCost, // 加盟费：0-是，1-否
                intentionRemind: this.intentionRemind, // 提点：0-高，1-低
                intentionTerm: this.intentionTerm, // 期限：0-是，1-否
                intentionOpinion: this.intentionOpinion // 意见
            }).then(result => {
                if (Number(result.data.StatusCode) === 0) {
                    layer.msg('修改成功')
                    this.$router.push(this.$route.matched[1].path)
                }
            }).catch(err => {
                console.log('考察阶段修改用户的加盟意向信息失败，异常信息：' + err)
            })
        }
    },
    computed: {
        ...mapGetters(['leftInfo'])
    }
}
</script>

